package com.sooncode.project.focusservice.service;

import com.sooncode.project.core.finder.Finder;
import com.sooncode.project.core.finder.Page;
import com.sooncode.project.core.finder.Sort;
import com.sooncode.project.focusservice.model.CourseScript;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class CourseScriptService {
    public boolean add(Map map){
        CourseScript courseScript=new CourseScript();
        courseScript.add(map);
        return true;
    }
    public boolean modify(String id,Map map){
        CourseScript courseScript=getById(id);
        courseScript.modify(map);
        return true;
    }
    public boolean delete(String id){
        CourseScript courseScript=getById(id);
        courseScript.delete();
        return true;
    }
    public Page<CourseScript> getPageList(int pageSize, int pageIndex, Map map){
        return new Finder<CourseScript>(CourseScript.class)
                .byMap(map)
                .page(pageSize,pageIndex,Sort.ASC("difficulty"));
    }
    public CourseScript getById(String id){
        return new Finder<CourseScript>(CourseScript.class).byId(id);
    }
    public List<CourseScript> getCourseScriptList(){
        return new Finder<CourseScript>(CourseScript.class).list(Sort.ASC("difficulty"));
    }
}
